function difference(arr1, arr2) {
    // 判断是否为空
    if (arr1.length === 0) {
        return [];
    }
    if (arr2.length === 0) {
        return arr1;
    }

    const result = arr1.filter(item => !arr2.includes(item));

    return result;
}

function difference2(arr1, arr2) {
    // 判断是否为空
    if (arr1.length === 0) {
        return [];
    }
    if (arr2.length === 0) {
        return arr1;
    }

    const result = []

    // 遍历数组
    for (let i = 0; i < arr1.length; i++) {
        // 判断元素是否在数组2中
        if (!arr2.includes(arr1[i])) {
            // 如果不在，则将元素添加到结果数组中
            result.push(arr1[i])
        }
    }

    return result;
}